def is_prime(n):
    if n < 2:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def nearest_prime(num):
    num = int(num)
    if num < 2:
        return 2
    samir = kolya = num
    while True:
        if is_prime(samir):
            return samir
        if is_prime(kolya):
            return kolya
        samir -= 1
        kolya += 1

def english_to_num(word):
    num_dict = {
        "zero": 0, "one": 1, "two": 2, "three": 3, "four": 4,
        "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9
    }
    return num_dict.get(word, None)

def main():
    words = input().split()
    if len(words) != 3:
        print("Wrong input")
        return
    num1, num2, num3 = words
    num1, num2, num3 = english_to_num(num1), english_to_num(num2), english_to_num(num3)
    if num1 is None or num2 is None or num3 is None:
        print("Wrong input")
        return
    num = num1 * 100 + num2 * 10 + num3
    if num < 100 or num > 999:
        print("Wrong input")
        return
    print(nearest_prime(num))

if __name__ == "__main__":
    main()
